define([
  'jquery',
  'underscore',
  'backbone',
  './programs'
], function( $, _, Backbone, ProgramsData) {
  'use strict';

  var Program,
      Programs;

  Program = Backbone.Model.extend({
    initialize: function(){
    } ,
    sync: function( method, model, options ) {
      console.log('program method:'+ method);
      if(typeof this[ method ]=== 'function'){

         this[ method ]( method, model, options );
      }
    }
    
  });

  Programs = Backbone.Collection.extend({
    model: Program,
    initialize: function(){
      this.on( 'remove', function( model, collection, options ) {
        model.destroy();
      }, this );
    },
    fetch: function( method, model, options) {
      var self = this;
      var  programsdata = ProgramsData.programs;



      //todo: backend ajax
      self.add( programsdata );
//      return $.ajax({
//        url: '/partner/shra/programs/src/programs.js',
//        success: function( data ) {
//          var items = data.programs;
//
//          if ( !items ) {
//            return;
//          }
//
//          self.add( items);
//        }
//      });
    }

  });

  var programs = new Programs();
  
  return programs;
});